package com.xd.core.business.controller;


import com.github.pagehelper.Page;
import com.xd.core.business.dto.EndorSementDto;
import com.xd.core.business.dto.GuaranteeQueryDto;
import com.xd.core.business.dto.GuaranteeReviewDto;
import com.xd.core.business.service.IGuaranteeSlipService;
import com.xd.core.business.vo.GuaranteePageVo;
import com.xd.core.business.vo.ReviewVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 保单表 前端控制器
 * </p>
 *
 * @author ZX
 * @since 2025-06-20
 */
@RestController
@RequestMapping("/guarantee-slip")
@Api(tags = "保单管理")
public class GuaranteeSlipController {

    @Autowired
    private IGuaranteeSlipService guaranteeSlipService;

    @PreAuthorize("hasAnyAuthority('sys:PolicyManagemnrt-viewDetails')")
    @PostMapping("/guaranteeList")
    @ApiOperation("保单列表分页查询")
    public Page<GuaranteePageVo> getGuaranteeList(@RequestBody GuaranteeQueryDto dto) {
        return guaranteeSlipService.getGuaranteeList(dto);
    }

    @GetMapping("/getReview/{guaranteeId}")
    @ApiOperation("复核数据回显及查看")
    public ReviewVo getReview(@PathVariable Integer guaranteeId) {
        return guaranteeSlipService.getReview(guaranteeId);
    }

    @PostMapping("/guaranteeReview")
    @ApiOperation("保单复核")
    public void guaranteeReview(@RequestBody GuaranteeReviewDto dto) {
        guaranteeSlipService.guaranteeReview(dto);
    }

    @PostMapping("/uploadSingle")
    @ApiOperation("单个保单文件上传")
    public void uploadSingle(@RequestBody EndorSementDto dto) {
        guaranteeSlipService.uploadSingle(dto);
    }

    @PostMapping("/uploadEndorSement")
    @ApiOperation("批单上传")
    public void uploadEndorSement(@RequestBody EndorSementDto dto) {
        guaranteeSlipService.uploadEndorSement(dto);
    }
}
